<template>
  <div id="jurisdiction"> 
    <el-form ref="form" :model="form" label-width="80px">  
     <el-row>   

        <el-col :span="12" style="display:flex;">


          <el-form-item label-width="0px" >
            <el-input v-model="form.input1" placeholder="姓名/手机号" class="search"></el-input>
          </el-form-item>

           <div class="custom_button" @click="soure_but"></div>
        </el-col>


         <el-col :span="12" style="text-align: right;">
           <el-button class="custom_color_button" type="primary" @click="set_but()">设置权限团队</el-button>
        </el-col>  
       
    </el-row>
   </el-form>

   <!-- 渲染数据list -->
   <jurisdiction-list :list="list" @up_list_fun='list_fun'> </jurisdiction-list>



      
   <div style="margin-top:20px;text-align: center;">
      <el-pagination
        background
        @current-change="handleCurrentChange"
        :page-size="10"  
        layout="prev, pager, next, jumper"
        :total="count">
      </el-pagination>
    </div>


        <!-- 设置团队权限 -->
        <el-dialog title="设置团队权限" :visible.sync="mtk"  width="500px">
            <div style="width:100%;"> 

           <el-form ref="form" :model="mtk_form" label-width="80px">  
                <el-row>   
                    <el-col :span="24" style="display:flex;">
                        <el-form-item label-width="0px" >
                            <el-input v-model="mtk_form.phone" placeholder="手机号" class="search"></el-input>
                        </el-form-item>

                        <div class="custom_button" @click="mtk_search()"></div>
                    </el-col>               
                </el-row>
                 <div style="width:100%;" v-if="show"> 

                    <div style="display:flex;align-items: center;margin-top:10px;">       
                        <div class="box1" >帐号</div>
                        <div style="padding:0px 15px;"></div>
                        <div class="box1" >所属团队</div>
                    </div>

                    <div style="display:flex;align-items: center;margin-top:10px;">
                     
                    <div class="box">
                     
                        <img  v-if="conter.self_icon"  style="width: 50px; height: 50px" :src="urlimg + conter.self_icon" /> 
                           <img  v-else src="@/assets/images/login_bg1.png" />
                        <div class="box_item">
                            <span>{{ conter.self_username }}</span>
                            <span>{{ conter.self_telphone }}</span>
                        </div>
                    </div>

                    <div style="padding:0px 15px;"><i class="el-icon-right"></i></div>

                    <div class="box">                      
                        <img v-if="conter.team_icon"  style="width: 30px; height: 30px" :src="urlimg + conter.team_icon" /> 
                        <img  v-else src="@/assets/images/login_bg1.png" />
                        <div class="box_item">
                            <span>{{ conter.team_username }}</span>
                            <span>{{ conter.team_telphone }}</span>
                        </div>
                    </div>

                  </div>
                    <div style="text-align: center;width:50%;margin:auto;margin-top:30px;">
                          <el-button type="primary" class="custom_color_button" style="width:100%;" @click="tj_but()">确认</el-button>
                    </div>
                
               </div>
            </el-form>

         

            </div> 
        </el-dialog>



    

      
  </div>
</template>

<script>
import JurisdictionList from '@/view/Member/JurisdictionList'
export default {
  name: 'jurisdiction',
  data () {
    return {
        form:{
           input1:'',
        },
        list:[],
        page:1,
        count:0,
        mtk:false,
        show:false,
        mtk_form:{
            phone:''
        },
       conter:{
          self_icon:'',
          self_telphone:'',
          self_uid:'',
          self_username:'',
          team_icon:'',
          team_telphone:'',
          team_username:'',
        }
    }
  },
 components:{
    JurisdictionList
  },
  created(){
      this.list_fun()
  },
  mounted (){
    
  },
  methods: {
      list_fun(){
          this.post("/goldbean/viceLeaderList", {
              page:this.page,
              telphone:this.form.input1
	        }).then(res => {
              this.count = res.result.count
              this.list = res.result.list
              //console.log(res)
         })
      },
     soure_but(){
         this.page = 1
         this.list_fun()
     },
     set_but(){
          this.mtk = true
     },
     mtk_search(){
           this.post("/goldbean/selectDetails", {
              telphone:this.mtk_form.phone,
	        }).then(res => {
              //console.log(res)
              if(res.error_code == 0){
                        this.show = true
                        this.conter.self_icon = res.result.self_icon
                        this.conter.self_telphone = res.result.self_telphone
                        this.conter.self_uid = res.result.self_uid
                        this.conter.self_username = res.result.self_username
                        this.conter.team_icon = res.result.team_icon
                        this.conter.team_telphone = res.result.team_telphone
                        this.conter.team_username =res.result.team_username
                }else {
                      this.open1(res.message,'warning')
                      this.conter={
                            self_icon:'',
                            self_telphone:'',
                            self_uid:'',
                            self_username:'',
                            team_icon:'',
                            team_telphone:'',
                            team_username:'',
                        }
                      this.show = false
             }
         })
     },
     tj_but(){
          this.post("/goldbean/addViceLeader", {
               uid:this.conter.self_uid,
	        }).then(res => {
                //console.log(res)
             if(res.error_code == 0){
                        this.open1(res.result,'success') 
                        this. conter={
                            self_icon:'',
                            self_telphone:'',
                            self_uid:'',
                            self_username:'',
                            team_icon:'',
                            team_telphone:'',
                            team_username:'',
                        }
                        this.mtk_form.phone = ''
                        this.show = false
                        this.mtk = false
                        this.list_fun()
                }else {
                      this.open1(res.message,'warning') 
                }

         })
     },
     handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        this.page = val
        this.list_fun()
        console.log(`当前页: ${val}`);
      }
  }
}
</script>


<style scoped>
.box{
    width: 200px;
    display: flex;
    border: 1px solid #DCDFE6;
    border-radius: 5px;
    padding:10px;
}
.box1{
    width: 200px;
    display: flex;
    padding:0px 10px;
    text-align: center;
}
.box>img{
    width: 50px;
    height: 50px;
    border-radius: 50%;
}
.box_item{
    flex: 1;
    margin-left:10px;
}
.box_item>span{
   display: block;
}
</style>
